﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
                    xmlns:resources="clr-namespace:WirelessAccessPoint.Resources">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Style/BaseStyle.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="HeaderBorderStyle" TargetType="{x:Type Border}">
        <Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}" />
        <Setter Property="BorderThickness" Value="0,1,0,1" />
        <Setter Property="BorderBrush" Value="{StaticResource HeaderBorderBrush}" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
    </Style>

    <Style x:Key="HeaderLabelStyle" TargetType="{x:Type Label}">
        <Setter Property="Foreground" Value="{StaticResource HeaderForegroundBrush}" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
    </Style>

    <Style x:Key="HeaderImageLabelStyle" TargetType="{x:Type Label}" BasedOn="{StaticResource HeaderLabelStyle}">
        <Setter Property="FontFamily" Value="/Resources/#FontAwesome" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Margin" Value="10,7,5,7" />
    </Style>

    <Style x:Key="HeaderTitleLabelStyle" TargetType="{x:Type Label}"  BasedOn="{StaticResource HeaderLabelStyle}">
        <Setter Property="Margin" Value="10,7,5,7" />
    </Style>

    <Style x:Key="ButtonLabelStyle" TargetType="{x:Type Label}">
        <Setter Property="Foreground" Value="{StaticResource ButtonForegroundBrush}" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
    </Style>

    <Style x:Key="ButtonImageLabelStyle" TargetType="{x:Type Label}" BasedOn="{StaticResource ButtonLabelStyle}">
        <Setter Property="FontFamily" Value="/Resources/#FontAwesome" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Margin" Value="5,5,5,5" />
    </Style>

    <Style x:Key="ButtonTitleLabelStyle" TargetType="{x:Type Label}" BasedOn="{StaticResource ButtonLabelStyle}">
        <Setter Property="Margin" Value="0,5,5,5" />
    </Style>

    <Style TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{StaticResource ButtonBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource ButtonBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Margin" Value="5,2,5,2" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3"
                            Margin="{TemplateBinding Margin}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                            VerticalAlignment="{TemplateBinding VerticalAlignment}">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{StaticResource ButtonMouseOverBackgroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Background" Value="{StaticResource ButtonPressedBackgroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource ButtonDisabledForegroundBrush}" />
                            <Setter Property="Background" Value="{StaticResource ButtonDisabledBackgroundBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type HeaderedContentControl}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type HeaderedContentControl}">
                    <DockPanel>
                        <Border DockPanel.Dock="Top" Style="{StaticResource HeaderBorderStyle}">
                            <ContentPresenter ContentSource="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" />
                        </Border>
                        <Border DockPanel.Dock="Bottom">
                            <ContentPresenter ContentSource="Content" ContentTemplate="{TemplateBinding ContentTemplate}" />
                        </Border>
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type TabControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <DockPanel Margin="{TemplateBinding Margin}">

                        <!--
                            ヘッダ部分は StatusHeaderTemplate.xaml のデータテンプレートを差し込みたいが
                            TabControl に HeaderTemplate は存在しないので Style にバインド含めてベタ書き
                        -->
                        <Border DockPanel.Dock="Top" Style="{StaticResource HeaderBorderStyle}">
                            <DockPanel LastChildFill="False">
                                <!--<Label DockPanel.Dock="Left" Content="&#xF00B;" Style="{StaticResource HeaderImageLabelStyle}" />-->
                                <Label DockPanel.Dock="Left" Content="{x:Static resources:LabelResource.StatusLabel}" Style="{StaticResource HeaderTitleLabelStyle}" />
                                <Button DockPanel.Dock="Right" Command="{Binding UpdateCommand}">
                                    <StackPanel Orientation="Horizontal">
                                        <Label Content="&#xF021;" Style="{StaticResource ButtonImageLabelStyle}" />
                                        <Label Content="{x:Static resources:LabelResource.UpdateLabel}" Style="{StaticResource ButtonTitleLabelStyle}" />
                                    </StackPanel>
                                </Button>
                                <StackPanel DockPanel.Dock="Right" IsItemsHost="True" Orientation="Horizontal" />
                            </DockPanel>
                        </Border>

                        <Border DockPanel.Dock="Bottom">
                            <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                <ContentPresenter ContentSource="SelectedContent" />
                            </ScrollViewer>
                        </Border>
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type TabItem}">
        <Setter Property="BorderThickness" Value="1,0,1,0" />
        <Setter Property="FontSize" Value="10" />
        <Setter Property="Foreground" Value="{StaticResource TabForegroundBrush}" />
        <Setter Property="Margin" Value="0,0,0,-1" />
        <Setter Property="Padding" Value="7,7,7,7" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Label x:Name="Label"
                           BorderThickness="{TemplateBinding BorderThickness}"
                           FontSize="{TemplateBinding FontSize}"
                           Foreground="{TemplateBinding Foreground}"
                           Margin="{TemplateBinding Margin}"
                           Padding="{TemplateBinding Padding}"
                           SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                           VerticalAlignment="{TemplateBinding VerticalAlignment}"
                           VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}">
                        <ContentPresenter ContentSource="Header" />
                    </Label>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" TargetName="Label" Value="{StaticResource CellEvenBackgroundBrush}" />
                            <Setter Property="BorderBrush" TargetName="Label" Value="{StaticResource CellBorderBrush}" />
                            <Setter Property="Foreground" TargetName="Label" Value="{StaticResource TabSelectedForegroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" SourceName="Label" Value="True">
                            <Setter Property="Background" TargetName="Label" Value="{StaticResource CellEvenBackgroundBrush}" />
                            <Setter Property="BorderBrush" TargetName="Label" Value="{StaticResource CellBorderBrush}" />
                            <Setter Property="Foreground" TargetName="Label" Value="{StaticResource TabSelectedForegroundBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
